package com.colin.aiyi.dao.ImpxUtils;

import com.colin.aiyi.app.Constant;
import com.colin.aiyi.entity.response.LoginResponse;
import com.colin.aiyi.entity.WXRequest;
import com.colin.aiyi.presenter.Interface.Callback;

import org.xutils.http.RequestParams;

/**
 * Created by hl on 2017/6/22.
 */

public class ImpCheckWXLogin extends AbsServicexUtils {

    @Override
    public void onSuccess(String result) {
        super.onSuccess(result);
        LoginResponse wxResponse=gson.fromJson(result,LoginResponse.class);
        if (callback==null)
        {
            sendMsgToView(wxResponse);
        }else {
            callback.onSuccess(wxResponse);
        }
    }
    public  <T, V>  void checkWXLogin(Callback<T> t, V v){
        this.callback=t;
        checkWXLogin(v);
    }
    /*********
     * account	是	string	第三方openId
     type	是	string	第三方类型（qq：qq weixin：微信 weibo：微博）
     * @param //baseRequest
     */
    public  <T> void checkWXLogin(T t){
        WXRequest baseRequest= (WXRequest) t;
        RequestParams params=new RequestParams(Constant.check_WX_Login);
        params.addBodyParameter("account",baseRequest.getOpenId());
        params.addBodyParameter("type",baseRequest.getAccountType());
//        params.addBodyParameter("code",baseRequest.getCode());
//        params.addBodyParameter("grant_type","authorization_code");
        sendToServer(params);
    }
}
